<template>
	<view class="user-center-setting">
		<cell-group>
		<!-- 	<cell-item title="新消息提醒" value="设置"></cell-item> -->
			//#ifdef APP-PLUS
			<cell-item title="当前版本" :value="version" v-if="version" :arrow="false"></cell-item>
			//#endif
			<cell-item title="关于我们" value="了解我们的服务" @click="navigateTo('/pages/userCenter/aboutUs')"></cell-item>
			<cell-item title="客服热线" value="0757 - 82138330" :arrow="false"></cell-item>
			<cell-item title="注销账号" value="请联系客服，平台将在3个工作日内处理" :border="false" :arrow="false"></cell-item>
		</cell-group>
		<view class="mt-60">
			<button class="app-primary-button" hover-class="app-primary-button-active" @click="logout">退出登录</button>
		</view>
		<view class="bottom display-flex align-center">
			<view class="bottom-text" @click="navigateTo('/pages/auth/protocol?readonly=true')">服务协议</view>
			<view class="bottom-text" @click="navigateTo('/pages/auth/privacy?readonly=true')">隐私政策</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue'
	import { auth } from '@/api'
	import { tip, storage } from '@/utils'
	import { useAuthStore } from '@/store/auth'
	import { useGoodsHistoryStore } from '@/store/goodsHistory'
	import { onLoad } from '@dcloudio/uni-app'
	
	const authStore = useAuthStore()
	const goodsHistoryStore = useGoodsHistoryStore()
	
	const version = ref('')
	
	onLoad(() => {
		//#ifdef APP-PLUS
		getVersion()
		//#endif
	})
	
	const logout = () => {
		auth.logout().then((res:any) => {
			storage.clearAllStorage(authStore,goodsHistoryStore)
			tip.showToast('登出成功！')
			uni.reLaunch({
				url:'/pages/auth/login'
			})
		})
	}
	
	const getVersion = () => {
		plus.runtime.getProperty(plus.runtime.appid as any, function(widgetInfo) {
			version.value = 'v.' + widgetInfo.version
		})
	}
	
	const navigateTo = (url:string) => {
		uni.navigateTo({url:url})
	}
</script>

<style lang="scss" scoped>
	.user-center-setting {
		margin-top: 20rpx;
		.bottom {
			position:fixed;
			bottom:150rpx;
			left:50%;
			transform: translateX(-50%);
			.bottom-text {
				color:#1769ff;
				font-size: 28rpx;
				padding: 0 15rpx;
			}
		}
	}
</style>

